<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        //  判断一个字符串 'abcedabcaa' 中出现次数最多的字符，并统计其次数。
        var str = 'abcedabcaca';
        var o = {};
        for (var i = 0; i < str.length; i++) {
            // 打印字符串中的每个字符
            // console.log(str.charAt(i));
            var char1 = str.charAt(i);
            if (o[char1]) {
                o[char1]++;
            } else {
                o[char1] = 1;
            }
        }
        // 每个字符出现次数
        console.log(o);
        console.log('---------------');
        var max = 0;
        for(var k in o ){
            if(max < o[k]){
                max = o[k];
            }
        }
        console.log('出现了'+max+'次');
        
    </script>
</body>

</html>